package com.ymatou.iapi.godmch.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.godmch.parameter.createIndepMchBean;
import com.ymatou.iapi.godmch.parameter.editmchBean;
import com.ymatou.iapi.godmch.parameter.getBuyerPicBean;
import com.ymatou.iapi.godmch.service.createIndepMchCall;
import com.ymatou.iapi.godmch.service.getBuyerPicCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.GodMemberService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
/**
*获取店铺分享图(买家端)
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getBuyerPic{
	private static getBuyerPicBean bean;
	private static getBuyerPicCall call;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取店铺分享图(买家端)");
	}

	@Before
	public void caseUp() {
		bean=new getBuyerPicBean();
		call=new getBuyerPicCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getBuyerPic_001() {
		Logger.start(true,"获取店铺分享图(买家端)-用户是独立商户-返回成功");
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            bean.setUserId(createIndepMchCall.getmchId());
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatus1(), "验证status");
		    Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证msg");
			Logger.verifyEquals(true,call.getResult().get("picUrl").toString().length()>0, "验证picUrl不为空");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getBuyerPic_002() {
		Logger.start(true,"获取店铺分享图(买家端)-用户是平台商户-返回成功");
		try {
			int userId=GodmchManageCallService.CreateSellerMch();
			editmchBean editmchBean=GodmchManageCallService.IniteditmachBean(userId);
			GodmchManageCallService.editmachCall(editmchBean);
			bean.setUserId(userId);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatus1(), "验证status");
		    Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证msg");
			Logger.verifyEquals(true,call.getResult().get("picUrl").toString().length()>0, "验证picUrl不为空");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getBuyerPic_003() {
		Logger.start(true,"获取店铺分享图(买家端)-用户不存在-返回成功");
		try {
			
			bean.setUserId(99999);
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("5000", call.getStatus1(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getBuyerPic_004() {
		Logger.start(true,"获取店铺分享图(买家端)-用户为空-返回失败");
		try {
			
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("4001", call.getStatus1(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getBuyerPic_005() {
		Logger.start(true,"获取店铺分享图(买家端)-用户是独立商户-分享机构(图片上显示邀请码)-返回成功");
		try {
//			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
//            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
//            bean.setUserId(createIndepMchCall.getmchId());
			Integer shopId=501608154;
			GodMemberService.setCollectionMobile(shopId, true);
			GodMemberService.setInvitationCodeCall(shopId,true, 0);
			
			bean.setUserId(shopId);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatus1(), "验证status");
		    Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证msg");
			Logger.verifyEquals(true,call.getResult().get("picUrl").toString().length()>0, "验证picUrl不为空");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}